<!DOCTYPE html>
<title>Tests that custom events with prefixed animations names are correctly dispatched.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var webkitAnimationStartReceived = false;
var webkitAnimationIterationReceived = false;

document.addEventListener('webkitAnimationStart', () => {
  webkitAnimationStartReceived = true;
});

document.addEventListener('webkitAnimationIteration', () => {
  webkitAnimationIterationReceived = true;
});

async_test(t => {
  document.addEventListener('animationstart', t.unreached_func('animationstart event listener should not have been called'));
  document.addEventListener('animationiteration', t.unreached_func('animationiteration event listener should not have been called'));
  document.addEventListener('animationend', t.unreached_func('animationend event listener should not have been called'));
  document.addEventListener('webkitAnimationEnd', t.step_func_done(() => {
    assert_true(webkitAnimationStartReceived);
    assert_true(webkitAnimationIterationReceived);
  }));

  var custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('webkitAnimationStart', true, true, null);
  document.dispatchEvent(custom);
  custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('webkitAnimationIteration', true, true, null);
  document.dispatchEvent(custom);
  custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('webkitAnimationEnd', true, true, null);
  document.dispatchEvent(custom);
}, "Tests that custom events with prefixed animations names are correctly dispatched");
</script>
